<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>generator_promise</title>
</head>
<body>
	<script type="text/javascript">
		function* gen(){
			yield 'apple';
			yield 'banana';
			yield 'fruit';
		}
		for (var i of gen()){
			console.log(i);
		}
		var iii=gen();
		console.log(iii);
		var i1=iii.next();
		console.log(i1.value);
		console.log(i1.done);
		var i2=iii.next();
		console.log(i2.value);
		console.log(i2.done);
		var i3=iii.next();
		console.log(i3.value);
		console.log(i3.done);
		var i4=iii.next();
		console.log(i4.value);
		console.log(i4.done);

		const www=gen();
		while(!(item=www.next()).done){
			console.log(item.value);
			console.log(item.done);
		} 

		function* geng(){
			yield 'apple';
			yield* gen();
			yield 'fruit';
		}
		const ggg=geng()
		for(var iii of geng()){
			console.info(iii);
		}
		//怎么上面是对象，下面是值呢
		function* idg(){
			let i=0;
			while(true){
				yield ++i;
			}
		}
		const idd=idg();//构造器生成函数生成迭代器
		const nn1={
			id:idd.next().value
		}
		const nn2={
			id:idd.next().value
		}
		const nn3={
			id:idd.next().value
		}
		const nn4={
			id:idd.next().value
		}
		console.log(nn1);//1
		console.log(nn2);//2
		console.log(nn3);//3
		console.log(nn4);//4

		// 在生成器函数中使用while(true) 不同标准函数 生成器=>迭代器
		
		





























	</script>
</body>
</html>